Skip to content

Conversation

awwyushh
Copy link

@awwyushh awwyushh commented Oct 3, 2025

Pull Request: Fix Rust generator issue with anyOf field naming conflicts

Description

This PR fixes a bug in the Rust client generator where an anyOf field in a response body that has the same name as a request parameter generates an empty struct instead of the expected type or enum. This issue occurs whether the anyOf contains a single variant or multiple variants.

The fix ensures that:

  • For anyOf fields with a single primitive type variant, the generated Rust struct uses the expected primitive type (e.g., Option<String>), instead of generating an empty struct wrapper.
  • For anyOf fields with multiple variants, the generator produces the expected Rust enum variant types.

This resolves the issue reported in [#22042](#22042) and was validated by running the generator against the minimal repro spec from the issue. The output matches the expected Rust struct and enum definitions.


How to verify

  1. Run mvn clean install -DskipTests -pl modules/openapi-generator-cli -am to build the CLI module after applying the patch.
  2. Generate Rust client code using the minimal repro OpenAPI spec provided in the issue.
  3. Confirm that the generated Rust code for the anyOf field no longer produces empty structs but the appropriate primitive type or enum.
  4. Verify that existing tests pass and no regressions occur.

Related issue

Fixes #22042


PR checklist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] [RUST] Empty field structs generated when name conflict between path parameter and response object field of same name using anyOf
1 participant